import { getRouteList, testTokenLogin } from "@/service/api.js";
import { useDispatch } from "react-redux";
import { Button } from "antd";
import { useNavigate } from "react-router-dom";
import "./index.scss";

const Login = () => {
  const dispatch = useDispatch();
  const navigate = useNavigate();
  const jumpToContent = async () => {
    //获取后端路由
    const res = await dispatch(getRouteList());
    if (res.payload && res.payload.code === 200) {
      navigate("/home");
    }
  };
  const handleClick = async () => {
    await dispatch(testTokenLogin());
  };
  return (
    <>
      <div className={"login-title"}>我是login页面</div>
      <Button onClick={jumpToContent}>跳转</Button>
      <div>
        <Button onClick={handleClick}>token无感刷新</Button>
      </div>
    </>
  );
};
export default Login;
